\(\int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx\) [5]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 32, antiderivative size = 44 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-a (A-i B) x-\frac {a A \cot (c+d x)}{d}+\frac {a (i A+B) \log (\sin (c+d x))}{d} \]

[Out]

-a*(A-I*B)*x-a*A*cot(d*x+c)/d+a*(I*A+B)*ln(sin(d*x+c))/d

Rubi [A] (verified)

Time = 0.11 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.094, Rules used = {3672, 3612, 3556} \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {a (B+i A) \log (\sin (c+d x))}{d}-a x (A-i B)-\frac {a A \cot (c+d x)}{d} \]

[In]

Int[Cot[c + d*x]^2*(a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

-(a*(A - I*B)*x) - (a*A*Cot[c + d*x])/d + (a*(I*A + B)*Log[Sin[c + d*x]])/d

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3672

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e
_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*c - a*d)*(A*b - a*B)*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1)*(a^2
+ b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[a*A*c + b*B*c + A*b*d - a*B*d - (A*b*
c - a*B*c - a*A*d - b*B*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0]
 && LtQ[m, -1] && NeQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {a A \cot (c+d x)}{d}+\int \cot (c+d x) (a (i A+B)-a (A-i B) \tan (c+d x)) \, dx \\ & = -a (A-i B) x-\frac {a A \cot (c+d x)}{d}+(a (i A+B)) \int \cot (c+d x) \, dx \\ & = -a (A-i B) x-\frac {a A \cot (c+d x)}{d}+\frac {a (i A+B) \log (\sin (c+d x))}{d} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.04 (sec) , antiderivative size = 97, normalized size of antiderivative = 2.20 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=i a B x-\frac {a A \cot (c+d x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(c+d x)\right )}{d}+\frac {i a A \log (\cos (c+d x))}{d}+\frac {a B \log (\cos (c+d x))}{d}+\frac {i a A \log (\tan (c+d x))}{d}+\frac {a B \log (\tan (c+d x))}{d} \]

[In]

Integrate[Cot[c + d*x]^2*(a + I*a*Tan[c + d*x])*(A + B*Tan[c + d*x]),x]

[Out]

I*a*B*x - (a*A*Cot[c + d*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[c + d*x]^2])/d + (I*a*A*Log[Cos[c + d*x]])/d
+ (a*B*Log[Cos[c + d*x]])/d + (I*a*A*Log[Tan[c + d*x]])/d + (a*B*Log[Tan[c + d*x]])/d

Maple [A] (verified)

Time = 0.17 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.34

method result size
parallelrisch \(\frac {\left (\left (-\frac {i A}{2}-\frac {B}{2}\right ) \ln \left (\sec ^{2}\left (d x +c \right )\right )+\left (i A +B \right ) \ln \left (\tan \left (d x +c \right )\right )-A \cot \left (d x +c \right )+x d \left (i B -A \right )\right ) a}{d}\) \(59\)
derivativedivides \(\frac {a \left (\frac {\left (-i A -B \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (i B -A \right ) \arctan \left (\tan \left (d x +c \right )\right )-\frac {A}{\tan \left (d x +c \right )}+\left (i A +B \right ) \ln \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(69\)
default \(\frac {a \left (\frac {\left (-i A -B \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (i B -A \right ) \arctan \left (\tan \left (d x +c \right )\right )-\frac {A}{\tan \left (d x +c \right )}+\left (i A +B \right ) \ln \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(69\)
risch \(-\frac {2 i a B c}{d}+\frac {2 a A c}{d}-\frac {2 i a A}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}+\frac {a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) B}{d}+\frac {i a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) A}{d}\) \(78\)
norman \(\frac {\left (i a B -a A \right ) x \tan \left (d x +c \right )-\frac {a A}{d}}{\tan \left (d x +c \right )}+\frac {\left (i a A +B a \right ) \ln \left (\tan \left (d x +c \right )\right )}{d}-\frac {\left (i a A +B a \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(82\)

[In]

int(cot(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

((-1/2*I*A-1/2*B)*ln(sec(d*x+c)^2)+(I*A+B)*ln(tan(d*x+c))-A*cot(d*x+c)+x*d*(-A+I*B))*a/d

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 62, normalized size of antiderivative = 1.41 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {-2 i \, A a + {\left ({\left (i \, A + B\right )} a e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (-i \, A - B\right )} a\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} - 1\right )}{d e^{\left (2 i \, d x + 2 i \, c\right )} - d} \]

[In]

integrate(cot(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

(-2*I*A*a + ((I*A + B)*a*e^(2*I*d*x + 2*I*c) + (-I*A - B)*a)*log(e^(2*I*d*x + 2*I*c) - 1))/(d*e^(2*I*d*x + 2*I
*c) - d)

Sympy [A] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 53, normalized size of antiderivative = 1.20 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=- \frac {2 i A a}{d e^{2 i c} e^{2 i d x} - d} + \frac {i a \left (A - i B\right ) \log {\left (e^{2 i d x} - e^{- 2 i c} \right )}}{d} \]

[In]

integrate(cot(d*x+c)**2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x)

[Out]

-2*I*A*a/(d*exp(2*I*c)*exp(2*I*d*x) - d) + I*a*(A - I*B)*log(exp(2*I*d*x) - exp(-2*I*c))/d

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 64, normalized size of antiderivative = 1.45 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left (d x + c\right )} {\left (A - i \, B\right )} a + {\left (i \, A + B\right )} a \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 2 \, {\left (i \, A + B\right )} a \log \left (\tan \left (d x + c\right )\right ) + \frac {2 \, A a}{\tan \left (d x + c\right )}}{2 \, d} \]

[In]

integrate(cot(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/2*(2*(d*x + c)*(A - I*B)*a + (I*A + B)*a*log(tan(d*x + c)^2 + 1) - 2*(I*A + B)*a*log(tan(d*x + c)) + 2*A*a/
tan(d*x + c))/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 104 vs. \(2 (40) = 80\).

Time = 0.49 (sec) , antiderivative size = 104, normalized size of antiderivative = 2.36 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=\frac {A a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 4 \, {\left (-i \, A a - B a\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + i\right ) + 2 \, {\left (i \, A a + B a\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right ) + \frac {-2 i \, A a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 2 \, B a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - A a}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}}{2 \, d} \]

[In]

integrate(cot(d*x+c)^2*(a+I*a*tan(d*x+c))*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

1/2*(A*a*tan(1/2*d*x + 1/2*c) + 4*(-I*A*a - B*a)*log(tan(1/2*d*x + 1/2*c) + I) + 2*(I*A*a + B*a)*log(tan(1/2*d
*x + 1/2*c)) + (-2*I*A*a*tan(1/2*d*x + 1/2*c) - 2*B*a*tan(1/2*d*x + 1/2*c) - A*a)/tan(1/2*d*x + 1/2*c))/d

Mupad [B] (verification not implemented)

Time = 7.23 (sec) , antiderivative size = 39, normalized size of antiderivative = 0.89 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x)) (A+B \tan (c+d x)) \, dx=-\frac {A\,a\,\mathrm {cot}\left (c+d\,x\right )}{d}+\frac {a\,\mathrm {atan}\left (2\,\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )\,2{}\mathrm {i}}{d} \]

[In]

int(cot(c + d*x)^2*(A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i),x)

[Out]

(a*atan(2*tan(c + d*x) + 1i)*(A*1i + B)*2i)/d - (A*a*cot(c + d*x))/d